package com.zxp.server.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxp.server.dto.BlogInfo;
import com.zxp.server.dto.BlogTagInfo;
import com.zxp.server.dto.RespPageBean;
import com.zxp.server.mapper.BlogMapper;
import com.zxp.server.mapper.BlogTagMapper;
import com.zxp.server.service.IBlogTagService;
import com.zxp.server.vo.BlogTag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 朱小皮
 * @since 2022-05-14
 */
@Service
public class BlogTagServiceImpl extends ServiceImpl<BlogTagMapper, BlogTag> implements IBlogTagService {

    @Autowired
    BlogTagMapper blogTagMapper;

    @Autowired
    BlogMapper blogMapper;

    @Override
    public List<BlogTagInfo> getSpecialTagInfo(){
        return blogTagMapper.getSpecialTagInfo();
    }

    @Override
    public RespPageBean getSpecialList(Integer currentPage, Integer size, Integer tagId) {
        Page<BlogInfo> blogPage = new Page<>(currentPage, size);
        IPage<BlogInfo> blogInfo = blogMapper.getSpecialList(blogPage,tagId);
        return new RespPageBean(blogInfo.getTotal(), blogInfo.getRecords());
    }
}
